<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class ScCollectionLog {
			
	// Instance
	private static $instance = null;
	
	private $scCollection;
	
	/**
	 * Constructeur priv�
	 */
	private function ScCollectionLog() {
		$this->scCollection = array();
	}
	
	/**
	 * Renvoie l'instance du singleton
	 */
	public static function getInstance() {
		if (!isset(self::$instance)) {
			$c = __CLASS__;
			self::$instance = new $c;
		}
		
		return self::$instance;
	}
	
	/**
	 * Permet d'ajouter un message
	 * @param MessageLog $mess
	 */
	public function addSc(ScLog $mess) {
		$this->scCollection[] = $mess;
	}
	
	/**
	 * Renvoie les messages de logs
	 */
	public function getMessage() {
		if (sizeOf($this->scCollection) > 0)
		{
			$str = "<table style=\\\"width:100%;\\\">";
			foreach ($this->scCollection as $mess) $str.= $mess->viewLog();
			$str.= "</table>";
			return $str;
		}
		return null;
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class ScLog {
	private $classname;
	private $props;
	
	/**
	 * Constructeur
	 * @param unknown_type $type
	 * @param unknown_type $message
	 */
	public function ScLog($classname, array $props) {
		$this->classname	= $classname;
		$this->props 		= $props;
	}
	
	public function viewLog() {
		$str = '<tr style=background:#eee;><td style=font-size:10px;vertical-align:top;>'.$this->classname.'</td><td style=font-size:10px;>';
		if (isset($this->props['ID'])) $str.= "<nobr><b>ID : ".$this->props['ID']."</b></nobr><br>";
		foreach ($this->props as $k => $v) {
			if (isset($v) && $k != 'ID' && !is_object($v)) $str.= "<nobr>".$k." : ".$v."</nobr><br>";
		}
		$str.= '</td></tr>';
		return $str;
	}
}
?>